import type {
  OrderPre,
  AddressItem,
  OrderDetail,
  Logistics
} from '@/types/order.d'
import { request } from '@/utils/request'

// 1. 获取药品订单的预支付信息
export const getMedicalOrderPre = (prescriptionId: string) =>
  request<OrderPre>('/patient/medicine/order/pre', 'GET', { prescriptionId })

// 2. 获取地址列表
export const getAddressList = () =>
  request<AddressItem[]>('/patient/order/address')

// 3. 创建药品订单
export const createMedicalOrder = (data: {
  id: string // 处方id
  addressId: string // 地址id
  couponId?: string // 优惠券id
}) => request<{ id: string }>('/patient/medicine/order', 'POST', data)

// 4. 获取药品订单详情
export const getMedicalOrderDetail = (id: string) =>
  request<OrderDetail>(`/patient/medicine/order/detail/${id}`)

// 5. 获取物流的详细信息
export const getMedicalOrderLogistics = (id: string) =>
  request<Logistics>(`/patient/order/${id}/logistics`)
